// 设置天际线

export function getSkyline(viewer = window.viewer, option = { color: "#fff8dc", width: 2, enabled: true }) {
    if (!viewer.bq_skyline) {
        viewer.bq_skyline = new mars3d.thing.Skyline(option)
        viewer.bq_skyline.ColorString = option.color
        viewer.addThing(viewer.bq_skyline)
    }
    return new Proxy(viewer.bq_skyline, {
        set(obj, key, value) {
            if (key === 'color') {
                obj[key] = value instanceof Cesium.Color ? value : Cesium.Color.fromCssColorString(value)
                obj.ColorString = value
            } else {
                obj[key] = value
            }
            if (viewer.scene.requestRenderMode) {
                viewer.scene.requestRender();
            }
            return true
        },
        get(obj, key) {
            if (key === 'color') {
                return obj.ColorString
            } else {
                return obj[key]
            }
        }
    })
}